
#ifndef __RSP__CMD_H__
#define __RSP__CMD_H__

#include "coid/comm/token.h"
#include "rsp_def.h"
#include "controller.h"

struct rsp_base;

///Use *inside* your class.
///Declares cmd() method that returns cmd_yourclass class containing all COMMAND decorated methods.
///The \a opt parameter optionally specifies parent class and a relative path how to get the header file where it's declared.
/// COMMAND_CLASS(warrior,"human:../baseobj/human.h")
///If the relative path isn't specified, a "./<baseclass>.h" is assumed.
#define COMMAND_CLASS(cls,opt) struct cmd_##cls; \
    cmd_##cls& cmd() { return *(cmd_##cls*)this; } \
    virtual void copy_constructor( const rsp_base& src ) { *(cls*)this = (const cls&)src; } \
    virtual rsp_base* new_constructor() const { return new cls; } \
    virtual void dispatch( const uchar* pc, const uchar* pe ); \
    virtual const token& class_name() const; \
    virtual const token& class_id() const; \
    static rsp_base* new_constructor_fn()  { return new cls; } \
    static cls* owned_instance() { return (cls*)rsp_controller::current->owned_instance(#cls); }

///Mark method as a command, options string defines command id and optional argument packing.
#define COMMAND(opt)


#endif //__RSP__CMD_H__
